<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>范例</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="crack.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.crack.html">Crack 函数</a></div>
 <div class="up"><a href="book.crack.html">Crack</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="crack.examples" class="appendix">
 <h1>范例</h1>

 <p class="para">
  This example shows how to open a CrackLib dictionary, test a given
  password, retrieve any diagnostic messages, and close the dictionary.
  <div class="example" id="example-801">
   <p><strong>Example #1 CrackLib example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Open&nbsp;CrackLib&nbsp;Dictionary<br /></span><span style="color: #0000BB">$dictionary&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">crack_opendict</span><span style="color: #007700">(</span><span style="color: #DD0000">'/usr/local/lib/pw_dict'</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">'Unable&nbsp;to&nbsp;open&nbsp;CrackLib&nbsp;dictionary'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Perform&nbsp;password&nbsp;check<br /></span><span style="color: #0000BB">$check&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">crack_check</span><span style="color: #007700">(</span><span style="color: #0000BB">$dictionary</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'gx9A2s0x'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Retrieve&nbsp;messages<br /></span><span style="color: #0000BB">$diag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">crack_getlastmessage</span><span style="color: #007700">();<br />echo&nbsp;</span><span style="color: #0000BB">$diag</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;'strong&nbsp;password'<br /><br />//&nbsp;Close&nbsp;dictionary<br /></span><span style="color: #0000BB">crack_closedict</span><span style="color: #007700">(</span><span style="color: #0000BB">$dictionary</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

  </div>
 </p>
 <blockquote class="note"><p><strong class="note">Note</strong>: 
  <p class="para">
   If <span class="function"><a href="function.crack-check.html" class="function">crack_check()</a></span> returns <strong><code>TRUE</code></strong>,
   <span class="function"><a href="function.crack-getlastmessage.html" class="function">crack_getlastmessage()</a></span> will return
   <em>&#039;strong password&#039;</em>.
  </p>
 </p></blockquote>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="crack.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.crack.html">Crack 函数</a></div>
 <div class="up"><a href="book.crack.html">Crack</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
